function checkWebGLError(gl)
{
    var errors = [];
    var err = undefined;
    while((err = gl.getError()) != gl.NO_ERROR) errors.push(err);
    if(errors.length != 0) throw ("WebGL errors: " + errors);
}


